import { dayRangeArray } from "@/utils";
const userData = [
  {
    id: 1,
    name: "场站一",
    children: [
      {
        id: 4,
        name: "用户一",
        children: [
          {
            id: 7,
            name: "终端一",
            children: [
              {
                id: 10,
                name: "设备一"
              },
              {
                id: 11,
                name: "设备二"
              },
              {
                id: 12,
                name: "设备三"
              }
            ]
          },
          {
            id: 8,
            name: "终端二"
          },
          {
            id: 9,
            name: "终端三"
          }
        ]
      },
      {
        id: 5,
        name: "用户二"
      },
      {
        id: 6,
        name: "用户三"
      }
    ]
  },
  {
    id: 2,
    name: "场站二"
  },
  {
    id: 3,
    name: "场站三"
  }
];
function getRandomInt(min, max) {
  return Math.random() * (max - min) + min;
}
const genData = (begin, end, randomBegin = 1000, randomEnd = 2000) => {
  let days = dayRangeArray(begin, end);
  let data = [];
  // days.map((item, index) => {
  //   return {
  //     dataDate: `${item} 00:00:00`,
  //     dataType: 1,
  //     id: index + 1,
  //     marketId: index + 1
  //   };
  // });
  days.forEach((i, index) => {
    new Array(2).fill(1).forEach((z, zindex) => {
      data.push({
        dataDate: `${i} 00:00:00`,
        dataType: zindex + 1,
        id: (index + 1) * (zindex + 1),
        marketId: (index + 1) * (zindex + 1)
      });
    });
  });
  let p96 = new Array(96).fill(1);
  data.forEach(item => {
    p96.forEach((key, kindex) => {
      item[`p${kindex + 1 > 9 ? kindex + 1 : "0" + (kindex + 1)}`] =
        getRandomInt(randomBegin, randomEnd).toFixed(4);
    });
  });
  return data;
};
const dayGenData = (begin, end, type = "day") => {
  let days = [];
  if (type === "day" || type === "month") {
    days = dayRangeArray(begin, end);
  } else {
    days = new Array(12)
      .fill(1)
      .map(
        (item, index) =>
          begin + `-${index + 1 > 9 ? index + 1 : "0" + (index + 1)}`
      );
  }
  let data = [];
  days.forEach(item => {
    data.push({
      time: item,
      value1: parseFloat(getRandomInt(0, 100).toFixed(2)),
      value2: parseFloat(getRandomInt(10000, 12000).toFixed(2)),
      value3: parseFloat(getRandomInt(9000, 10000).toFixed(2)),
      value4: parseFloat(getRandomInt(14000, 16000).toFixed(2)),
      value5: parseFloat(getRandomInt(12000, 14000).toFixed(2)),
      value6: parseFloat(getRandomInt(0, 100).toFixed(2)),
      value7: parseFloat(getRandomInt(0, 100).toFixed(2))
    });
  });
  return data;
};
const tqType = [
  {
    id: 1,
    name: "地表温度(℃)",
    key: "dbwd"
  },
  {
    id: 2,
    name: "地表气压(Pa)",
    key: "dbqy"
  },
  {
    id: 3,
    name: "2m气温(℃)",
    key: "qw"
  },
  {
    id: 4,
    name: "2m湿度(g/kg)",
    key: "sd"
  },
  {
    id: 5,
    name: "短波辐射(W/㎡)",
    key: "dbfs"
  },
  {
    id: 6,
    name: "累计降水量(mm)",
    key: "ljjs"
  },
  {
    id: 7,
    name: "累计降雪量(mm)",
    key: "ljjx"
  },
  {
    id: 8,
    name: "10m风速(m/s)",
    key: "fs"
  },
  {
    id: 9,
    name: "10m风向(度)",
    key: "fx"
  },
  {
    id: 10,
    name: "云量(%)",
    key: "yl"
  },
  {
    id: 11,
    name: "时段内降雨量(mm)",
    key: "jy"
  },
  {
    id: 12,
    name: "时段内降雪量(mm)",
    key: "jx"
  }
];
export { userData, genData, tqType, dayGenData };
